package w4

import java.io.{FileInputStream, ObjectInputStream}
import scala.collection.mutable.ListBuffer

case class Card(val no: Int, val name: String) extends Serializable

class SuperMarket(val name: String, val phone: String) extends Serializable {
  private var cards = ListBuffer[Card]()

  def add(c: Card) = {
  }

  def inc(no: Int, score: Int) = {

  }

  def show() = {

  }

  def exchange(t: Int): String = {
    "meiyou"
  }
}

object SuperMarket {
  def main(args: Array[String]): Unit = {
    var sp = SuperMarket()
    while (true) {

    }
  }

  //异常处理
  def apply(): Unit = {
    val oin = new ObjectInputStream(new FileInputStream("sp.obj"))
    var sp = oin.readObject()

    if (sp.isInstanceOf[SuperMarket]) {
      sp = sp.asInstanceOf[SuperMarket]
    } else {
      sp = new SuperMarket("合家福", "1939333")
    }
    sp
  }
}
